from datetime import date

from openai import OpenAI
from datetime import datetime

def create_voice(client, content):
    response = client.audio.speech.create(
        model="tts-1-hd",
        voice="nova",
        input=content,
    )
    current_time = datetime.now().time()
    print("当前时间:", current_time)
    formatted_time = str(current_time) + current_time.strftime("%H_%M_%S_")
    response.stream_to_file((str(formatted_time) + ".mp3"))

if __name__ == '__main__':
    client = OpenAI(api_key="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")
    # str="Welcome to Lyfy, your partner in personal health and wellness. We're excited to embark on this journey with you, offering personalized, evidence-based lifestyle medicine guidance to help you lead a healthier, happier life. Explore our features, connect with our community, and start transforming your lifestyle today.",
    conttent="张总，李总，王总，谢总，大家好，我们齐聚一堂，就是为了大展宏图，为了全人类更好的明天，大家不要在乎现在拿多少回报，因为未来的舞台是无限大的"
    create_voice(client, conttent)
